MkAdmonition
Admonition info box.¶
Example: Types¶
Example: Collapsible and expandable¶
Jinja
Python
Expand me!
Admonitions can also be collapsible.
Example: Inlined¶
Bases: MkContainer
__init__
¶
__init__(
content: str | list | MkNode,
*,
typ: AdmonitionTypeStr | str = "info",
title: str | None = None,
collapsible: bool = False,
expanded: bool = False,
inline: Literal["left", "right"] | None = None,
**kwargs: Any
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str | list | MkNode
|
Admonition content |
required |
typ
|
AdmonitionTypeStr | str
|
Admonition type |
'info'
|
title
|
str | None
|
Optional Admonition title |
None
|
collapsible
|
bool
|
Whether Admontion can get collapsed by user |
False
|
expanded
|
bool
|
Initial state if collapsible is set |
False
|
inline
|
Literal['left', 'right'] | None
|
Whether admonition should rendered as inline block |
None
|
kwargs
|
Any
|
Keyword arguments passed to parent |
{}
|
Name | Children | Inherits |
---|---|---|
MkContainer mknodes.basenodes.mkcontainer A node containing other MkNodes. |
graph TD
94721311723232["mkadmonition.MkAdmonition"]
94721311697232["mkcontainer.MkContainer"]
94721308848336["mknode.MkNode"]
94721311766592["node.Node"]
140564252373184["builtins.object"]
94721311697232 --> 94721311723232
94721308848336 --> 94721311697232
94721311766592 --> 94721308848336
140564252373184 --> 94721311766592
/home/runner/work/mknodes/mknodes/mknodes/basenodes/mkadmonition/metadata.toml
[metadata]
icon = "octicon:info-16"
name = "MkAdmonition"
[requirements.extension.admonition]
[requirements.extension."pymdownx.details"]
[requirements.extension."pymdownx.superfences"]
[examples.annotations]
title = "Annotations"
python = """
import mknodes as mk
node = mk.MkAdmonition("MkAdmonitions can carry annotations(1).")
node.annotations[1] = "Super handy!"
node
"""
[examples.types]
title = "Types"
jinja = """
{{ "Different types." | MkAdmonition(typ="warning") }}
"""
[examples.collapsible]
title = "Collapsible and expandable"
jinja = """
{{ "Admonitions can also be collapsible." | MkAdmonition(collapsible=True, title="Expand me!", expanded=True) }}
"""
[examples.inlined]
title = "Inlined"
jinja = """
{{ "Inlined" | MkAdmonition(inline="left") }}
"""
[output.markdown]
template = """
{% if node.title or node.items %}
{{ node.title_line }}
{{ node.items | join(node.block_separator) | indent(first=True) }}
{% endif %}
"""
[output.block]
template = """
{{ node.fence_boundary }} admonition {{ node.typ }}{{ node.title | add(" | ") }}
{{ node.items | join }}
{{ node.fence_boundary }}
"""
[output.github]
template = """
> [!{{ node.typ | upper }}]\
{{ node.items | join | indent(width="> ", first=True) }}
"""
[output.rst]
template = """
.. {{ node.typ }}:: {{ node.title or "" }}
{{ node.items | join(node.block_separator) | indent(first=True) }}
"""